/**
 * org.assess.oa.system.dao.impl.TbUserDAOImpl
 */
package org.assess.oa.system.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.assess.core.dao.BaseDAOImpl;
import org.assess.oa.system.bean.TbUser;
import org.assess.oa.system.dao.TbUserDAO;

/**
 * @description 操作用户表的DAO实现类
 * @author XiaLongxiang
 * @createtime 2012-5-17 下午12:07:47
 */
public class TbUserDAOImpl extends BaseDAOImpl<TbUser> implements TbUserDAO {
    public TbUser queryTbUserByCode(String user_code, String valid_flag) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("user_code", user_code);
        map.put("valid_flag", valid_flag);
        return (TbUser) sqlClient.queryForObject("queryTbUserByCode", map);
    }
    
    public int queryTbUserAsInt(Map<String, Object> parameters) {
        return (Integer) sqlClient.queryForObject("queryTbUserAsInt", parameters);
    }
    
    @SuppressWarnings("unchecked")
    public List<TbUser> queryTbUserAsList(int startNum, int rows, Map<String, Object> parameters) {
        return sqlClient.queryForList("queryTbUserAsList", parameters, startNum, rows);
    }
    
    public boolean updateTbUserValid(TbUser user) {
        int count = sqlClient.update("updateTbUserValid", user);
        return count > 0;
    }
    
    public boolean updateUserLoginTime(TbUser user) {
        int count = sqlClient.update("updateUserLoginTime", user);
        return count > 0;
    }
}
